<template>
  <div>
    <button @click="exitFn">退出登录</button>
    <button @click="UnbindFn">解绑微信</button>
  </div>
</template>

<script>
import { mapMutations, mapActions } from "vuex";
import { unbindWeChatAPI } from "@/request/api";
export default {
  name: "JifenNoeCenter",

  data() {
    return {};
  },

  mounted() {},

  methods: {
    ...mapMutations({
      changeIsLoginedShow: "loginStatus/changeIsLoginedShow",
      initUserInfo: "userInfo/initUserInfo",
    }),
    ...mapActions({
      asyncchangeIsShowToast: "showToast/asyncchangeIsShowToast",
    }),
    exitFn() {
      localStorage.removeItem("x-auth-token");
      this.changeIsLoginedShow(false);
      this.initUserInfo();
      this.asyncchangeIsShowToast({
        isShow: true,
        msg: "您已退出登录,两秒后返回首页",
        type: "success",
      });
      setTimeout(() => {
        this.$router.push("/home");
      }, 2000);
    },
    async UnbindFn() {
      let res = await unbindWeChatAPI();
      //   console.log("微信解绑", res);
      this.asyncchangeIsShowToast({
        isShow: true,
        msg: res.data,
        type: "success",
      });
    },
  },
};
</script>

<style lang="less" scoped>
button {
  display: block;
  width: 100px;
  height: 40px;
  background-color: #0a328e;
  color: white;
  border: none;
  border-radius: 5px;
  margin-top: 20px;
  font-size: 16px;
}
</style>